package com.mcintyret.site.validation.password;

import org.hibernate.validator.constraints.NotBlank;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Pattern;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * User: mcintyret2
 * Date: 11/04/2012
 */

@Documented
@Constraint(validatedBy = {})
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@NotBlank(message = "{com.mcintyret.constraints.password.null}")
@Pattern.List({
        @Pattern(regexp = ".*[A-Z].*", message = "{com.mcintyret.constraints.password.uppercase}" ),
        @Pattern(regexp = ".*[a-z].*", message = "{com.mcintyret.constraints.password.lowercase}" ),
        @Pattern(regexp = ".*[\\d].*", message = "{com.mcintyret.constraints.password.digits}" )
})
public @interface Password {

    String message() default "{com.mcintyret.constraints.password}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
